package com.bitBusy.manageyourriches.database.contactClasses;


/** Expense detail for a given category and subcategory*/
public class ExpenseDetails{

	
	/**Date/time of expense*/
	private String myDateTime;
	
	/**payment method*/
	private String myPaymentMethod;
	
	/**amount*/
	private double myAmount;
	
	/**notes*/
	private String myNote;
	
	/**Constructor*/
	public ExpenseDetails(String the_dateTime, String the_paymentMethod, double the_amount, String the_note)
	{
		myDateTime = the_dateTime;
		myPaymentMethod = the_paymentMethod;
		myAmount = the_amount;
		myNote = the_note;
	}
	
	/**Get datetime
	 * @return string
	 */
	public String getDateTime()
	{
		return myDateTime;
	}
	
	/**Get payment method
	 * @return string
	 */
	public String getPaymentMethod()
	{
		return myPaymentMethod;
	}
	
	/** get amount
	 * @return double
	 */
	public double getAmount()
	{
		return myAmount;
	}
	
	/**Get note
	 * @return string
	 */
	public String getNote()
	{
		return myNote;
	}

	/** compares with another object of this class
	 * @param the_expense
	 * @return true if equal
	 */
	public boolean isEqual(ExpenseDetails the_expense) {
		if (the_expense != null && isDateTimeEqual(the_expense.getDateTime()) && isPaymentInfoEqual(the_expense.getPaymentMethod()) && 
				isAmountEqual(the_expense.getAmount()) && isNoteEqual(the_expense.getNote()))
		{
			return true;
		}
		return false;
	}
		
	/** checks if datetime equal
	 * @param datetime
	 * @return boolean
	 */
	private boolean isDateTimeEqual(String the_dateTime)
	{
			if ((the_dateTime == null && myDateTime == null) ||
				(the_dateTime != null && myDateTime != null && the_dateTime.equals(myDateTime)))
			{
				return true;
			}
			return false;
	}
	
	/** checks if paymentinfo equal
	 * @param paymentinfo
	 * @return boolean
	 */
	private boolean isPaymentInfoEqual(String the_paymentInfo)
	{
			if ((the_paymentInfo == null && myPaymentMethod == null) ||
				(the_paymentInfo != null && myPaymentMethod != null && the_paymentInfo.equals(myPaymentMethod)))
			{
				return true;
			}
			return false;
	}
	
	/** checks if amount equal
	 * @param paymentinfo
	 * @return boolean
	 */
	private boolean isAmountEqual(double the_amount)
	{
			if(the_amount == myAmount)
			{
				return true;
			}
			return false;
	}
	
	/** checks if note equal
	 * @param note
	 * @return boolean
	 */
	private boolean isNoteEqual(String the_note)
	{
			if ((the_note == null && myNote == null) ||
				(the_note != null && myNote != null && the_note.equals(myNote)))
			{
				return true;
			}
			return false;
	}
	


}
